package org.hot100_3;

public class leetcode101 {
    public boolean isSymmetric(TreeNode root) {

        return method(root.left, root.right);
    }

    private boolean method(TreeNode left, TreeNode right) {

        if (left == null && right == null) {
            return true;
        }

        if (left == null && right != null) {
            return false;
        }

        if (left != null && right == null) {
            return false;
        }

        if (left.val != right.val) {
            return false;
        }


        boolean outside = method(left.left, right.right);

        boolean inside = method(left.right, right.left);

        return outside && inside;
    }
}
